package AdvancedEncryptionStandard;

import org.apache.commons.codec.binary.Hex;

public class AesTestData {
    private static final AES aes = new AES();
    private final String key;
    private final String plaintext;
    private final String ciphertext;

    public AesTestData(String key, String plaintext, String ciphertext) {
        this.key = key;
        this.plaintext = plaintext;
        this.ciphertext = ciphertext;
    }

    public ByteStream getPlaintext() {
        ByteStream plaintextStream = null;
        try {
            byte[] plaintextByte = Hex.decodeHex(plaintext);
            plaintextStream = new ByteStream(plaintextByte, 16);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return plaintextStream;
    }

    public ByteStream getCiphertext() {
        ByteStream ciphertextStream = null;
        try {
            byte[] ciphertextByte = Hex.decodeHex(ciphertext);
            ciphertextStream = new ByteStream(ciphertextByte, 16);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return ciphertextStream;
    }

    public ByteStream[] getKey() {
        ByteStream[] keyStreams = null;
        try {
            keyStreams = aes.generateKey(new ByteStream(Hex.decodeHex(key), 16), 10);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return keyStreams;
    }

}
